// use sessionStorage to store the authority info, which might be sent from server in actual project.
import Cookies from 'js-cookie';

let currentPermissions = null;
const initAuthority = 1;

export function getAuthority() {
    const Token = Cookies.get('token');
    if (!Token) {
        return null;
    }
    // return sessionStorage.getItem('antd-pro-authority');
    // 统一输出字符串数组
    const authorityStr = currentPermissions
        ? `${initAuthority},${currentPermissions}`
        : `${initAuthority}`;
    return authorityStr.split(',');
}

export function setAuthority(authority) {
    currentPermissions = authority;
}
